package com.ibm.commerce.url.tasks.orgadminconsole;

/**
 * Info 1
 * Info 2
 * Info 3
 * Info 4
 * Info 5
 * Info 6
 */

import com.ibm.commerce.url.harness.*;
import com.ibm.commerce.url.util.Log;
import com.ibm.commerce.url.exception.*;
import com.ibm.wc.test.exception.DatablockMissingException;

import java.util.LinkedHashMap;
import java.util.Map;

public class OrgAdminConsoleLogon extends URLTestTask {

	public static final String INPUT_PARAMETER_NAME_LOGONID = "logonId";
	public static final String INPUT_PARAMETER_NAME_LOGONPASSWORD = "logonPassword";
	public static final String INPUT_PARAMETER_NAME_LANGID = "langId";
	
	private static OrgAdminConsoleLogon instance = new OrgAdminConsoleLogon();
	private OrgAdminConsoleLogon(){}
	
	public static void execute() throws TaskFailException, DatablockMissingException {
		instance.runTask();
	}
	public static void execute(int counterIndex) throws TaskFailException, DatablockMissingException {
		instance.runTask(counterIndex);
	}
	
	protected void executeTask() throws TaskFailException {
		orgAdminConsoleLogonStep1();
		orgAdminConsoleLogonStep2();
		orgAdminConsoleLogonStep3();
	}

	private void orgAdminConsoleLogonStep1() throws TaskFailException {
		Log.finest("Task["+this.getClass().getSimpleName()+"]: Entering orgAdminConsoleLogonStep1");
		WebHit("https://standardhost/orgadminconsole", WEB_FORM_GET);
		Log.finest("Task["+this.getClass().getSimpleName()+"]: Exiting orgAdminConsoleLogonStep1");
	}
	
	private static Map<String, String> orgAdminConsoleLogonStep2_FORM = new LinkedHashMap<String, String>();
	static{
		orgAdminConsoleLogonStep2_FORM.put("XMLFile","buyerconsole.BuyAdminConsoleLogon");
	}
	private void orgAdminConsoleLogonStep2() throws TaskFailException{
		Log.finest("Task["+this.getClass().getSimpleName()+"]: Entering orgAdminConsoleLogonStep2");

		WebHit("https://standardhost/webapp/wcs/orgadmin/servlet/ToolsLogon", WEB_FORM_POST, orgAdminConsoleLogonStep2_FORM);
		
		Log.finest("Task["+this.getClass().getSimpleName()+"]: Exiting orgAdminConsoleLogonStep2");	
	}
	
	private static Map<String, String> orgAdminConsoleLogonStep3_FORM = new LinkedHashMap<String, String>();
	static{
		orgAdminConsoleLogonStep3_FORM.put("BrowserOk","true");
		orgAdminConsoleLogonStep3_FORM.put("XMLFile","buyerconsole.BuyAdminConsoleLogon");
		orgAdminConsoleLogonStep3_FORM.put("langId","");
		orgAdminConsoleLogonStep3_FORM.put("URL","BuyAdminConLaunched");
		orgAdminConsoleLogonStep3_FORM.put("slurl","BuyAdminConLaunched");
		orgAdminConsoleLogonStep3_FORM.put("mcurl","BuyAdminConsoleView");
		orgAdminConsoleLogonStep3_FORM.put("reLogonURL","ToolsLogon?XMLFile=buyerconsole.BuyAdminConsoleLogon");		
		orgAdminConsoleLogonStep3_FORM.put("logonId","");
		orgAdminConsoleLogonStep3_FORM.put("logonPassword","");
		orgAdminConsoleLogonStep3_FORM.put("storeId","0");
	}
	private static Map<String, String> OrgAdminConsoleLogon_BUYA003 = new LinkedHashMap<String, String>();
	static{
		OrgAdminConsoleLogon_BUYA003.put("storeId","0");
		OrgAdminConsoleLogon_BUYA003.put("XMLFile","buyerconsole.BuySiteAdminConsole");
	}
	private void orgAdminConsoleLogonStep3() throws TaskFailException{	
		Log.finest("Task["+this.getClass().getSimpleName()+"]: Entering orgAdminConsoleLogonStep3");
		
		// Add dynamically changed URL parameters begin
		putParameterInMap(orgAdminConsoleLogonStep3_FORM, "logonId", getParameterFromDataFile(INPUT_PARAMETER_NAME_LOGONID));
		putParameterInMap(orgAdminConsoleLogonStep3_FORM, "logonPassword", getParameterFromDataFile(INPUT_PARAMETER_NAME_LOGONPASSWORD));
		putParameterInMap(orgAdminConsoleLogonStep3_FORM, "langId", getParameterFromDataFile(INPUT_PARAMETER_NAME_LANGID));
		
		// Add dynamically changed URL parameters end
		
		// Add global URL parameters begin
		//putParameterInMap(orgAdminConsoleLogonStep3_FORM, "anotherParam", getParameterFromGlobalMap("logonPassword"));
		// Add global URL parameters end
		
		// Main body start
		WebHit("https://standardhost/webapp/wcs/orgadmin/servlet/Logon", WEB_FORM_POST, orgAdminConsoleLogonStep3_FORM);
		WebHit("https://standardhost/webapp/wcs/orgadmin/servlet/BuyAdminConsoleView", WEB_FORM_GET, OrgAdminConsoleLogon_BUYA003);
		GUIValidate("var homepage = 'BuyAdminConHome';");
		WebHit("https://standardhost/webapp/wcs/orgadmin/servlet/ToolsUIBanner", WEB_FORM_GET);
		WebHit("https://standardhost/webapp/wcs/orgadmin/servlet/ToolsUIMenu", WEB_FORM_GET);
		WebHit("https://standardhost/webapp/wcs/orgadmin/servlet/ToolsUIMain", WEB_FORM_GET);
		WebHit("https://standardhost/webapp/wcs/orgadmin/servlet/BuyAdminConHome", WEB_FORM_GET);
		
		// Main body end	
		
		// Save global URL parameters begin		
		// Save global URL parameters end
		
		// Save task output parameters begin		
		// Save task output parameters end
		
		Log.finest("Task["+this.getClass().getSimpleName()+"]: Exiting orgAdminConsoleLogonStep3");
	}
	
}
